<!DOCTYPE html>
<html lang="zh-CN" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>背景 | 静思田园</title>
    <meta name="description" content="时不时记录一点点">
    <meta name="generator" content="VitePress v1.5.0">
    <link rel="preload stylesheet" href="/assets/style.D1KHeDuB.css" as="style">
    <link rel="preload stylesheet" href="/vp-icons.css" as="style">
    <script type="module" src="/assets/chunks/metadata.d4b76d32.js"></script>
    <script type="module" src="/assets/app.Cqoht_Of.js"></script>
    <link rel="preload" href="/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
    <link rel="modulepreload" href="/assets/chunks/framework.trnLO_3_.js">
    <link rel="modulepreload" href="/assets/chunks/theme.BNMYWj-o.js">
    <link rel="modulepreload" href="/assets/chunks/katex.BZy9Y_85.js">
    <link rel="modulepreload" href="/assets/chunks/c4Diagram-3d4e48cf.rhyfUO3k.js">
    <link rel="modulepreload" href="/assets/chunks/flowDiagram-66a62f08.BvVfKYLl.js">
    <link rel="modulepreload" href="/assets/chunks/flowDiagram-v2-96b9c2cf.rYAPEXyw.js">
    <link rel="modulepreload" href="/assets/chunks/erDiagram-9861fffd.CQSbaoJM.js">
    <link rel="modulepreload" href="/assets/chunks/gitGraphDiagram-72cf32ee.CjLmC8RV.js">
    <link rel="modulepreload" href="/assets/chunks/ganttDiagram-c361ad54.R_V-FeK5.js">
    <link rel="modulepreload" href="/assets/chunks/infoDiagram-f8f76790.C-2Va9KZ.js">
    <link rel="modulepreload" href="/assets/chunks/pieDiagram-8a3498a8.B9ZVkD7K.js">
    <link rel="modulepreload" href="/assets/chunks/quadrantDiagram-120e2f19.BuonnDHi.js">
    <link rel="modulepreload" href="/assets/chunks/xychartDiagram-e933f94c.C_bIYaUn.js">
    <link rel="modulepreload" href="/assets/chunks/requirementDiagram-deff3bca.RFVzvdjl.js">
    <link rel="modulepreload" href="/assets/chunks/sequenceDiagram-704730f1.UZWxMlyq.js">
    <link rel="modulepreload" href="/assets/chunks/classDiagram-70f12bd4.sipmPMFa.js">
    <link rel="modulepreload" href="/assets/chunks/classDiagram-v2-f2320105.CDkLxQ0T.js">
    <link rel="modulepreload" href="/assets/chunks/stateDiagram-587899a1.CD2ocVZB.js">
    <link rel="modulepreload" href="/assets/chunks/stateDiagram-v2-d93cdb3a.D0qUPm3J.js">
    <link rel="modulepreload" href="/assets/chunks/journeyDiagram-49397b02.CeUUZA2l.js">
    <link rel="modulepreload" href="/assets/chunks/flowchart-elk-definition-4a651766.DkdgpMTf.js">
    <link rel="modulepreload" href="/assets/chunks/timeline-definition-85554ec2.WL9yxus9.js">
    <link rel="modulepreload" href="/assets/chunks/mindmap-definition-fc14e90a.CWC2bxmB.js">
    <link rel="modulepreload" href="/assets/chunks/sankeyDiagram-04a897e0.BXj8OViR.js">
    <link rel="modulepreload" href="/assets/chunks/blockDiagram-38ab4fdb.CPVnJXk5.js">
    <link rel="modulepreload" href="/assets/chunks/virtual_mermaid-config.DDnGl6nM.js">
    <link rel="modulepreload" href="/assets/frontend_css_背景.md.B9yrMR0j.lean.js">
    <meta name="application-name" content="VuePress">
    <meta name="apple-mobile-web-app-title" content="静思田园">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="msapplication-TileColor" content="#3eaf7c">
    <meta name="theme-color" content="#646cff">
    <meta name="HandheldFriendly" content="True">
    <meta name="MobileOptimized" content="320">
    <script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
    <script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
  </head>
  <body>
    <div id="app"><div class="Layout" data-v-5d98c3a5><!--[--><!--]--><!--[--><span tabindex="-1" data-v-0f60ec36></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-0f60ec36> Skip to content </a><!--]--><!----><header class="VPNav" data-v-5d98c3a5 data-v-ae24b3ad><div class="VPNavBar" data-v-ae24b3ad data-v-6aa21345><div class="wrapper" data-v-6aa21345><div class="container" data-v-6aa21345><div class="title" data-v-6aa21345><div class="VPNavBarTitle has-sidebar" data-v-6aa21345 data-v-1168a8e4><a class="title" href="/" data-v-1168a8e4><!--[--><!--]--><!--[--><img class="VPImage logo" src="/logo.png" alt data-v-8426fc1a><!--]--><span data-v-1168a8e4>静思田园</span><!--[--><!--]--></a></div></div><div class="content" data-v-6aa21345><div class="content-body" data-v-6aa21345><!--[--><!--]--><div class="VPNavBarSearch search" data-v-6aa21345><!--[--><!----><div id="local-search"><button type="button" class="DocSearch DocSearch-Button" aria-label="搜索文档"><span class="DocSearch-Button-Container"><span class="vp-icon DocSearch-Search-Icon"></span><span class="DocSearch-Button-Placeholder">搜索文档</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-6aa21345 data-v-dc692963><span id="main-nav-aria-label" class="visually-hidden" data-v-dc692963> Main Navigation </span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57></span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/network/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>网络工程师</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/frontend/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>前端</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/English/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>English</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/Scrupy/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>爬虫</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/backend/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>后端</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/bigdata/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>大数据</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/computer/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>计算机基础</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/database/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>数据库</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/docker/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>dorker</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/git/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>Git</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/nodejs/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>Node.js</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/python/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>Python</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/shell/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>shell</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/tools/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>工具</span><!--]--></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-6aa21345 data-v-6c893767><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-6c893767 data-v-5337faa4 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-5337faa4></span><span class="vpi-moon moon" data-v-5337faa4></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-6aa21345 data-v-0394ad82 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/loveagri" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-bd121fe5><span class="vpi-social-github"></span></a><a class="VPSocialLink no-icon" href="https://gitee.com/loveagri" aria-label target="_blank" rel="noopener" data-v-7bc22406 data-v-bd121fe5><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>码云</title><path d="M11.984 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.016 0zm6.09 5.333c.328 0 .593.266.592.593v1.482a.594.594 0 0 1-.593.592H9.777c-.982 0-1.778.796-1.778 1.778v5.63c0 .327.266.592.593.592h5.63c.982 0 1.778-.796 1.778-1.778v-.296a.593.593 0 0 0-.592-.593h-4.15a.592.592 0 0 1-.592-.592v-1.482a.593.593 0 0 1 .593-.592h6.815c.327 0 .593.265.593.592v3.408a4 4 0 0 1-4 4H5.926a.593.593 0 0 1-.593-.593V9.778a4.444 4.444 0 0 1 4.445-4.444h8.296Z"/></svg></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-6aa21345 data-v-bb2aa2f0 data-v-cf11d7a2><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-cf11d7a2><span class="vpi-more-horizontal icon" data-v-cf11d7a2></span></button><div class="menu" data-v-cf11d7a2><div class="VPMenu" data-v-cf11d7a2 data-v-b98bc113><!----><!--[--><!--[--><!----><div class="group" data-v-bb2aa2f0><div class="item appearance" data-v-bb2aa2f0><p class="label" data-v-bb2aa2f0>Appearance</p><div class="appearance-action" data-v-bb2aa2f0><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-bb2aa2f0 data-v-5337faa4 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-5337faa4></span><span class="vpi-moon moon" data-v-5337faa4></span><!--]--></span></span></button></div></div></div><div class="group" data-v-bb2aa2f0><div class="item social-links" data-v-bb2aa2f0><div class="VPSocialLinks social-links-list" data-v-bb2aa2f0 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/loveagri" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-bd121fe5><span class="vpi-social-github"></span></a><a class="VPSocialLink no-icon" href="https://gitee.com/loveagri" aria-label target="_blank" rel="noopener" data-v-7bc22406 data-v-bd121fe5><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>码云</title><path d="M11.984 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.016 0zm6.09 5.333c.328 0 .593.266.592.593v1.482a.594.594 0 0 1-.593.592H9.777c-.982 0-1.778.796-1.778 1.778v5.63c0 .327.266.592.593.592h5.63c.982 0 1.778-.796 1.778-1.778v-.296a.593.593 0 0 0-.592-.593h-4.15a.592.592 0 0 1-.592-.592v-1.482a.593.593 0 0 1 .593-.592h6.815c.327 0 .593.265.593.592v3.408a4 4 0 0 1-4 4H5.926a.593.593 0 0 1-.593-.593V9.778a4.444 4.444 0 0 1 4.445-4.444h8.296Z"/></svg></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-6aa21345 data-v-e5dd9c1c><span class="container" data-v-e5dd9c1c><span class="top" data-v-e5dd9c1c></span><span class="middle" data-v-e5dd9c1c></span><span class="bottom" data-v-e5dd9c1c></span></span></button></div></div></div></div><div class="divider" data-v-6aa21345><div class="divider-line" data-v-6aa21345></div></div></div><!----></header><div class="VPLocalNav has-sidebar empty" data-v-5d98c3a5 data-v-a6f0e41e><div class="container" data-v-a6f0e41e><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-a6f0e41e><span class="vpi-align-left menu-icon" data-v-a6f0e41e></span><span class="menu-text" data-v-a6f0e41e>Menu</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-v-a6f0e41e data-v-17a5e62e><button data-v-17a5e62e>Return to top</button><!----></div></div></div><aside class="VPSidebar" data-v-5d98c3a5 data-v-319d5ca6><div class="curtain" data-v-319d5ca6></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-319d5ca6><span class="visually-hidden" id="sidebar-aria-label" data-v-319d5ca6> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="no-transition group" data-v-c40bc020><section class="VPSidebarItem level-0 has-active" data-v-c40bc020 data-v-b7550ba0><div class="item" role="button" tabindex="0" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><h2 class="text" data-v-b7550ba0>CSS</h2><!----></div><div class="items" data-v-b7550ba0><!--[--><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/frontend/css/" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>CSS</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/frontend/css/css%E5%9F%BA%E7%A1%80.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>基础知识</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/frontend/css/%E5%8F%98%E5%BD%A2%E5%8A%A8%E7%94%BB.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>变形动画</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/frontend/css/%E5%93%8D%E5%BA%94%E5%BC%8F.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>响应式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/frontend/css/%E5%AA%92%E4%BD%93%E6%9F%A5%E8%AF%A2.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>媒体查询</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/frontend/css/%E5%AE%9A%E4%BD%8D%E5%B8%83%E5%B1%80.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>定位布局</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/frontend/css/%E5%B8%A7%E5%8A%A8%E7%94%BB.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>帧动画</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/frontend/css/%E5%BC%B9%E6%80%A7%E5%B8%83%E5%B1%80.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>弹性布局</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/frontend/css/%E6%95%B0%E6%8D%AE%E6%A0%B7%E5%BC%8F.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>数据样式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/frontend/css/%E6%96%87%E6%9C%AC.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>文本</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/frontend/css/%E6%A0%85%E6%A0%BC%E7%B3%BB%E7%BB%9F.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>栅格系统</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/frontend/css/%E6%B5%AE%E5%8A%A8%E5%B8%83%E5%B1%80.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>浮动布局</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/frontend/css/%E7%9B%92%E5%AD%90%E6%A8%A1%E5%9E%8B.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>盒子模型</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/frontend/css/%E8%83%8C%E6%99%AF.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>背景</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/frontend/css/%E9%80%89%E6%8B%A9%E5%99%A8.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>选择器</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-5d98c3a5 data-v-1428d186><div class="VPDoc has-sidebar has-aside" data-v-1428d186 data-v-39a288b8><!--[--><!--]--><div class="container" data-v-39a288b8><div class="aside" data-v-39a288b8><div class="aside-curtain" data-v-39a288b8></div><div class="aside-container" data-v-39a288b8><div class="aside-content" data-v-39a288b8><div class="VPDocAside" data-v-39a288b8 data-v-3f215769><!--[--><!--]--><!--[--><!--]--><nav aria-labelledby="doc-outline-aria-label" class="VPDocAsideOutline" data-v-3f215769 data-v-a5bbad30><div class="content" data-v-a5bbad30><div class="outline-marker" data-v-a5bbad30></div><div aria-level="2" class="outline-title" id="doc-outline-aria-label" role="heading" data-v-a5bbad30>目录</div><ul class="VPDocOutlineItem root" data-v-a5bbad30 data-v-b933a997><!--[--><!--]--></ul></div></nav><!--[--><!--]--><div class="spacer" data-v-3f215769></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-39a288b8><div class="content-container" data-v-39a288b8><!--[--><!--]--><main class="main" data-v-39a288b8><div style="position:relative;" class="vp-doc _frontend_css_%E8%83%8C%E6%99%AF" data-v-39a288b8><div><h1 id="背景" tabindex="-1">背景 <a class="header-anchor" href="#背景" aria-label="Permalink to &quot;背景&quot;">​</a></h1><h3 id="背景颜色" tabindex="-1">背景颜色 <a class="header-anchor" href="#背景颜色" aria-label="Permalink to &quot;背景颜色&quot;">​</a></h3><p><code>background-color</code>背景颜色可以使用 <code>rga | rgba | 十六进制</code> 等颜色格式</p><h3 id="背景图片" tabindex="-1">背景图片 <a class="header-anchor" href="#背景图片" aria-label="Permalink to &quot;背景图片&quot;">​</a></h3><p>可以使用 <code>png| gif |jpeg</code> 等图片做为背景使用</p><div class="language-css line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">background-image</span><span style="color:#C678DD;">: url(</span><span style="color:#E06C75;">icon-s</span><span style="color:#D19A66;">.jpg</span><span style="color:#ABB2BF;">);</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h3 id="背景裁切" tabindex="-1">背景裁切 <a class="header-anchor" href="#背景裁切" aria-label="Permalink to &quot;背景裁切&quot;">​</a></h3><table tabindex="0"><thead><tr><th style="text-align:left;">选项</th><th style="text-align:left;">说明</th></tr></thead><tbody><tr><td style="text-align:left;">border-box</td><td style="text-align:left;">包括边框</td></tr><tr><td style="text-align:left;">padding-box</td><td style="text-align:left;">不含边框，包括内边距</td></tr><tr><td style="text-align:left;">content-box</td><td style="text-align:left;">内容区域</td></tr></tbody></table><div class="language-css line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">background-clip</span><span style="color:#C678DD;">: </span><span style="color:#E06C75;">border-box</span><span style="color:#C678DD;">;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h3 id="背景重复" tabindex="-1">背景重复 <a class="header-anchor" href="#背景重复" aria-label="Permalink to &quot;背景重复&quot;">​</a></h3><p>用于设置背景重复的规则</p><table tabindex="0"><thead><tr><th style="text-align:left;">选项</th><th style="text-align:left;">说明</th></tr></thead><tbody><tr><td style="text-align:left;">repeat</td><td style="text-align:left;">水平、垂直重复</td></tr><tr><td style="text-align:left;">repeat-x</td><td style="text-align:left;">水平重复</td></tr><tr><td style="text-align:left;">repeat-y</td><td style="text-align:left;">垂直重复</td></tr><tr><td style="text-align:left;">no-repeat</td><td style="text-align:left;">不重复</td></tr><tr><td style="text-align:left;">space</td><td style="text-align:left;">背景图片对称均匀分布，中间有间隙，自适应</td></tr></tbody></table><div class="language- line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span>background-repeat: repeat-y</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h3 id="背景滚动" tabindex="-1">背景滚动 <a class="header-anchor" href="#背景滚动" aria-label="Permalink to &quot;背景滚动&quot;">​</a></h3><p>用于设置在页面滚动时的图片处理方式</p><table tabindex="0"><thead><tr><th style="text-align:left;">选项</th><th style="text-align:left;">说明</th></tr></thead><tbody><tr><td style="text-align:left;">scroll</td><td style="text-align:left;">背景滚动</td></tr><tr><td style="text-align:left;">fixed</td><td style="text-align:left;">背景固定</td></tr></tbody></table><div class="language-css line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#D19A66;">    .background-attachement-main</span><span style="color:#ABB2BF;"> {</span></span>
<span class="line"><span style="color:#ABB2BF;">        height: </span><span style="color:#D19A66;">500</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        border: </span><span style="color:#D19A66;">1</span><span style="color:#E06C75;">px</span><span style="color:#D19A66;"> solid</span><span style="color:#D19A66;"> #000</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        overflow: </span><span style="color:#D19A66;">auto</span></span>
<span class="line"><span style="color:#ABB2BF;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#D19A66;">    .background-attachement</span><span style="color:#ABB2BF;"> {</span></span>
<span class="line"><span style="color:#ABB2BF;">        height: </span><span style="color:#D19A66;">3000</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        background: </span><span style="color:#56B6C2;">url</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;https://images.pexels.com/photos/15258473/pexels-photo-15258473.jpeg?auto=compress&amp;cs=tinysrgb&amp;w=400&amp;lazy=load&#39;</span><span style="color:#ABB2BF;">) </span><span style="color:#D19A66;">no-repeat</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">       background-attachment: </span><span style="color:#D19A66;">fixed</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">       color: </span><span style="color:#D19A66;">#fff</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">    }</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;/</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span><span style="color:#C678DD;">   </span></span>
<span class="line"><span style="color:#C678DD;">&lt;</span><span style="color:#E06C75;">div</span><span style="color:#C678DD;"> class=&quot;</span><span style="color:#E06C75;">background-attachement-main</span><span style="color:#C678DD;">&quot;</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#C678DD;">    &lt;</span><span style="color:#E06C75;">div</span><span style="color:#C678DD;"> class=&quot;</span><span style="color:#E06C75;">background-attachement</span><span style="color:#C678DD;">&quot;</span><span style="color:#ABB2BF;">&gt;</span><span style="color:#C678DD;">hello world&lt;</span><span style="color:#ABB2BF;">/</span><span style="color:#E06C75;">div</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#C678DD;">&lt;</span><span style="color:#ABB2BF;">/</span><span style="color:#E06C75;">div</span><span style="color:#ABB2BF;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div><div class="background-attachement-main"><div class="background-attachement">hello world</div></div><h3 id="背景位置" tabindex="-1">背景位置 <a class="header-anchor" href="#背景位置" aria-label="Permalink to &quot;背景位置&quot;">​</a></h3><p>用于设置背景图片的水平、垂直定位，可以设置多张图片的位置。</p><table tabindex="0"><thead><tr><th style="text-align:left;">选项</th><th style="text-align:left;">说明</th></tr></thead><tbody><tr><td style="text-align:left;">left</td><td style="text-align:left;">左对齐</td></tr><tr><td style="text-align:left;">right</td><td style="text-align:left;">右对齐</td></tr><tr><td style="text-align:left;">center</td><td style="text-align:left;">居中对齐</td></tr><tr><td style="text-align:left;">top</td><td style="text-align:left;">顶端对齐</td></tr><tr><td style="text-align:left;">bottom</td><td style="text-align:left;">底部对齐</td></tr></tbody></table><h4 id="居中对齐" tabindex="-1">居中对齐 <a class="header-anchor" href="#居中对齐" aria-label="Permalink to &quot;居中对齐&quot;">​</a></h4><div class="language-css line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">background-position</span><span style="color:#C678DD;">: center;</span></span>
<span class="line"><span style="color:#C678DD;">或</span></span>
<span class="line"><span style="color:#E06C75;">background-position</span><span style="color:#C678DD;">: 50% 50%;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h4 id="水平居右-垂直居中" tabindex="-1">水平居右，垂直居中 <a class="header-anchor" href="#水平居右-垂直居中" aria-label="Permalink to &quot;水平居右，垂直居中&quot;">​</a></h4><div class="language-css line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">background-position</span><span style="color:#C678DD;">: right center;</span></span>
<span class="line"><span style="color:#C678DD;">或</span></span>
<span class="line"><span style="color:#E06C75;">background-position</span><span style="color:#C678DD;">: 100% 50%;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h4 id="使用具体数值定义" tabindex="-1">使用具体数值定义 <a class="header-anchor" href="#使用具体数值定义" aria-label="Permalink to &quot;使用具体数值定义&quot;">​</a></h4><div class="language-css line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">background-position</span><span style="color:#C678DD;">: 100px 100px;</span></span>
<span class="line"><span style="color:#C678DD;">也支持使用负值</span></span>
<span class="line"><span style="color:#E06C75;">background-position</span><span style="color:#C678DD;">: -200px 100px;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h4 id="设置多张图片位置" tabindex="-1">设置多张图片位置 <a class="header-anchor" href="#设置多张图片位置" aria-label="Permalink to &quot;设置多张图片位置&quot;">​</a></h4><div class="language-css line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">background-position</span><span style="color:#C678DD;">: 0 0</span><span style="color:#ABB2BF;">,</span><span style="color:#C678DD;"> -15px 15px</span><span style="color:#ABB2BF;">,</span><span style="color:#C678DD;"> 15px -15px</span><span style="color:#ABB2BF;">,</span><span style="color:#C678DD;"> 0 0;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h3 id="背景尺寸" tabindex="-1">背景尺寸 <a class="header-anchor" href="#背景尺寸" aria-label="Permalink to &quot;背景尺寸&quot;">​</a></h3><table tabindex="0"><thead><tr><th style="text-align:left;">选项</th><th style="text-align:left;">说明</th></tr></thead><tbody><tr><td style="text-align:left;">cover</td><td style="text-align:left;">背景完全覆盖，可能会有背景溢出</td></tr><tr><td style="text-align:left;">contain</td><td style="text-align:left;">图片不溢出的放在容器中，可能会漏出部分区域</td></tr></tbody></table><p>指定数值定义宽高尺寸</p><div class="language-css line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">background-size</span><span style="color:#C678DD;">: 50% 100%;</span></span>
<span class="line"><span style="color:#C678DD;">或</span></span>
<span class="line"><span style="color:#E06C75;">background-size</span><span style="color:#C678DD;">: 200px 200px;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>宽度固定高度自动</p><div class="language-css line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">background-size</span><span style="color:#C678DD;">: 50% auto;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h3 id="多个背景" tabindex="-1">多个背景 <a class="header-anchor" href="#多个背景" aria-label="Permalink to &quot;多个背景&quot;">​</a></h3><p>后定义的背景置于底层</p><div class="language-css line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">background-image</span><span style="color:#C678DD;">: url(</span><span style="color:#E06C75;">xj-small</span><span style="color:#D19A66;">.png</span><span style="color:#ABB2BF;">), </span><span style="color:#C678DD;">url(bg</span><span style="color:#D19A66;">.png</span><span style="color:#ABB2BF;">);</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>多属性定义</p><div class="language-css line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">background-image</span><span style="color:#C678DD;">: url(</span><span style="color:#E06C75;">xj-small</span><span style="color:#D19A66;">.png</span><span style="color:#ABB2BF;">), </span><span style="color:#C678DD;">url(bg</span><span style="color:#D19A66;">.png</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#E06C75;">background-repeat</span><span style="color:#C678DD;">: </span><span style="color:#E06C75;">no-repeat</span><span style="color:#C678DD;">;</span></span>
<span class="line"><span style="color:#E06C75;">background-position</span><span style="color:#C678DD;">: top left</span><span style="color:#ABB2BF;">,</span><span style="color:#C678DD;"> right bottom;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>可以一次定义多个背景图片。</p><div class="language-css line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#C678DD;">background: url(x</span><span style="color:#D19A66;">.png</span><span style="color:#ABB2BF;">) </span><span style="color:#C678DD;">left 50% </span><span style="color:#E06C75;">no-repeat</span><span style="color:#ABB2BF;">,</span></span>
<span class="line"><span style="color:#C678DD;">                url(bg</span><span style="color:#D19A66;">.png</span><span style="color:#ABB2BF;">) </span><span style="color:#C678DD;">right 100% </span><span style="color:#E06C75;">no-repeat</span><span style="color:#C678DD;"> red;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="组合设置" tabindex="-1">组合设置 <a class="header-anchor" href="#组合设置" aria-label="Permalink to &quot;组合设置&quot;">​</a></h3><p>可以使用一条指令设置背景</p><div class="language-css line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#C678DD;">background: red url(1</span><span style="color:#D19A66;">.png</span><span style="color:#ABB2BF;">) </span><span style="color:#E06C75;">no-repeat</span><span style="color:#C678DD;"> right 50% fixed;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="盒子阴影" tabindex="-1">盒子阴影 <a class="header-anchor" href="#盒子阴影" aria-label="Permalink to &quot;盒子阴影&quot;">​</a></h2><p>可以使用 <code>box-shadow</code> 对盒子元素设置阴影，参数为 <code>水平偏移,垂直偏移,模糊度,颜色</code> 构成。</p><div class="language-html line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#D19A66;">    .box-shadow</span><span style="color:#ABB2BF;"> {</span></span>
<span class="line"><span style="color:#ABB2BF;">        width: </span><span style="color:#D19A66;">200</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        height: </span><span style="color:#D19A66;">200</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        background-color: </span><span style="color:#D19A66;">#ccc</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        box-shadow: </span><span style="color:#D19A66;">10</span><span style="color:#E06C75;">px</span><span style="color:#D19A66;"> 10</span><span style="color:#E06C75;">px</span><span style="color:#D19A66;"> 5</span><span style="color:#E06C75;">px</span><span style="color:#D19A66;"> #888888</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">    }</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;/</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">div</span><span style="color:#D19A66;"> class</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;box-shadow&quot;</span><span style="color:#ABB2BF;">&gt;&lt;/</span><span style="color:#E06C75;">div</span><span style="color:#ABB2BF;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><div class="box-shadow"></div><h2 id="颜色渐变" tabindex="-1">颜色渐变 <a class="header-anchor" href="#颜色渐变" aria-label="Permalink to &quot;颜色渐变&quot;">​</a></h2><p>标志位：颜色过度的起始值和终止值即为标志位，起始和终止中间的部分为颜色本身，没有过度。可以通过微信截图，活动滑动鼠标观察rgb的值的变化。</p><div class="language-html line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#D19A66;">    .linear-gradient-mark</span><span style="color:#ABB2BF;"> {</span></span>
<span class="line"><span style="color:#ABB2BF;">        height: </span><span style="color:#D19A66;">100</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        border: </span><span style="color:#D19A66;">1</span><span style="color:#E06C75;">px</span><span style="color:#D19A66;"> solid</span><span style="color:#D19A66;"> #000</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">        /* 25%、60%、80%、100%即为标志位 */</span></span>
<span class="line"><span style="color:#ABB2BF;">        background-image: </span><span style="color:#56B6C2;">linear-gradient</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">90</span><span style="color:#E06C75;">deg</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">red</span><span style="color:#D19A66;"> 25</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">blue</span><span style="color:#D19A66;"> 60</span><span style="color:#E06C75;">%</span><span style="color:#D19A66;"> 80</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">green</span><span style="color:#D19A66;"> 100</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#ABB2BF;">    }</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;/</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">div</span><span style="color:#D19A66;"> class</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;linear-gradient-mark&quot;</span><span style="color:#ABB2BF;">&gt;&lt;/</span><span style="color:#E06C75;">div</span><span style="color:#ABB2BF;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><div class="linear-gradient-mark"></div><input type="range" value="25" style="width:100%;" disabled><input type="range" value="60" style="width:100%;" disabled><input type="range" value="80" style="width:100%;" disabled><p>中间值：两个过度颜色中间的位置即为中间值，表示，颜色渐变的中间的某个位置，可以调节，设置其过度的位置。</p><div class="language-html line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">div</span><span style="color:#D19A66;"> class</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;linear-gradient-25&quot;</span><span style="color:#ABB2BF;">&gt;&lt;/</span><span style="color:#E06C75;">div</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#D19A66;">    .linear-gradient-25</span><span style="color:#ABB2BF;"> {</span></span>
<span class="line"><span style="color:#ABB2BF;">        height: </span><span style="color:#D19A66;">100</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        border: </span><span style="color:#D19A66;">1</span><span style="color:#E06C75;">px</span><span style="color:#D19A66;"> solid</span><span style="color:#D19A66;"> #000</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">         /* 25%即为中间值 */</span></span>
<span class="line"><span style="color:#ABB2BF;">        background-image: </span><span style="color:#56B6C2;">linear-gradient</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">90</span><span style="color:#E06C75;">deg</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">red</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">25</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">blue</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#ABB2BF;">    }</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;/</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">div</span><span style="color:#D19A66;"> class</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;linear-gradient-5&quot;</span><span style="color:#ABB2BF;">&gt;&lt;/</span><span style="color:#E06C75;">div</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">input</span><span style="color:#D19A66;"> type</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;range&quot;</span><span style="color:#D19A66;"> value</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;25&quot;</span><span style="color:#D19A66;"> style</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;width: 100%;&quot;</span><span style="color:#D19A66;"> disabled</span><span style="color:#ABB2BF;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><div class="linear-gradient-50"></div><input type="range" value="50" style="width:100%;" disabled><div class="linear-gradient-25"></div><input type="range" value="25" style="width:100%;" disabled><h3 id="线性渐变" tabindex="-1">线性渐变 <a class="header-anchor" href="#线性渐变" aria-label="Permalink to &quot;线性渐变&quot;">​</a></h3><p><strong>粗暴理解</strong>：在两个颜色之间， 比如<code>红色</code>和<code>黄色</code>，通过<code>0点</code>和<code>100%点</code>的色值，计算出中间<code>50%</code>位置的色值， 然后再通过<code>0% 50%</code>， <code>50% 100%</code>计算出<code>25%</code>，<code>75%</code>的色值，以此类推。 多个颜色的话就分别以相邻两个颜色的终点来计算两者之间的渐变色。</p><p><strong>渐变中心点</strong>：默认渐变中心点为两个色值点的中间值，可通过参数移动中间点。以<code>linear-gradient(30deg, red 10% , yellow 30%, blue 70%)</code>为例，在红色向黄色渐变时，默认的渐变中心点在两者正中的位置，也就是20%的位置。<code>linear-gradient(30deg, red 10% , 15%, yellow 30%, blue 70%)</code>，通过在两者之间设定值，可以将中心点移动到<code>15%</code>的位置。</p><div class="tip custom-block"><p class="custom-block-title">提示</p><p>可以通过微信截图或者其它截图工具观察rgba变化理解线性渐变。下方可放置多个进度条作为参考。</p><div class="language-html line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#D19A66;">    .linear-gradient-0</span><span style="color:#ABB2BF;"> {</span></span>
<span class="line"><span style="color:#ABB2BF;">        height: </span><span style="color:#D19A66;">200</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        border: </span><span style="color:#D19A66;">1</span><span style="color:#E06C75;">px</span><span style="color:#D19A66;"> solid</span><span style="color:#D19A66;"> #000</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        background-color: yellowgreen;</span></span>
<span class="line"><span style="color:#ABB2BF;">        background-image: </span><span style="color:#56B6C2;">linear-gradient</span><span style="color:#ABB2BF;">(to </span><span style="color:#D19A66;">right</span><span style="color:#ABB2BF;">, </span><span style="color:#56B6C2;">rgba</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">255</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">0</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">0</span><span style="color:#ABB2BF;">) </span><span style="color:#D19A66;">0</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">blue</span><span style="color:#D19A66;"> 10</span><span style="color:#E06C75;">%</span><span style="color:#D19A66;"> 30</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">yellow</span><span style="color:#D19A66;"> 50</span><span style="color:#E06C75;">%</span><span style="color:#D19A66;"> 70</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">green</span><span style="color:#D19A66;"> 90</span><span style="color:#E06C75;">%</span><span style="color:#D19A66;"> 100</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#ABB2BF;">}</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;/</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">div</span><span style="color:#D19A66;"> class</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;linear-gradient-0&quot;</span><span style="color:#ABB2BF;">&gt;&lt;/</span><span style="color:#E06C75;">div</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">input</span><span style="color:#D19A66;"> type</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;range&quot;</span><span style="color:#D19A66;"> value</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;10&quot;</span><span style="color:#D19A66;"> style</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;width: 100%;&quot;</span><span style="color:#D19A66;"> disabled</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">input</span><span style="color:#D19A66;"> type</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;range&quot;</span><span style="color:#D19A66;"> value</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;30&quot;</span><span style="color:#D19A66;"> style</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;width: 100%;&quot;</span><span style="color:#D19A66;"> disabled</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">input</span><span style="color:#D19A66;"> type</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;range&quot;</span><span style="color:#D19A66;"> value</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;50&quot;</span><span style="color:#D19A66;"> style</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;width: 100%;&quot;</span><span style="color:#D19A66;"> disabled</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">input</span><span style="color:#D19A66;"> type</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;range&quot;</span><span style="color:#D19A66;"> value</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;70&quot;</span><span style="color:#D19A66;"> style</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;width: 100%;&quot;</span><span style="color:#D19A66;"> disabled</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">input</span><span style="color:#D19A66;"> type</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;range&quot;</span><span style="color:#D19A66;"> value</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;90&quot;</span><span style="color:#D19A66;"> style</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;width: 100%;&quot;</span><span style="color:#D19A66;"> disabled</span><span style="color:#ABB2BF;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><div class="linear-gradient-0"></div><input type="range" value="10" style="width:100%;" disabled><input type="range" value="30" style="width:100%;" disabled><input type="range" value="50" style="width:100%;" disabled><input type="range" value="70" style="width:100%;" disabled><input type="range" value="90" style="width:100%;" disabled></div><h4 id="硬过度理解渐变参数" tabindex="-1">硬过度理解渐变参数 <a class="header-anchor" href="#硬过度理解渐变参数" aria-label="Permalink to &quot;硬过度理解渐变参数&quot;">​</a></h4><h5 id="示例1" tabindex="-1">示例1 <a class="header-anchor" href="#示例1" aria-label="Permalink to &quot;示例1&quot;">​</a></h5><p><em>一个线性渐变的黄绿色背景图像。<code>45deg</code>表示渐变的方向为逆时针<code>45</code>度。<code>rgba(255, 0, 0,.3)</code>表示一种不带有透明度的红色，这里的<code>1</code>表示<code>100%</code>的不透明。背景图像分为四段，第一段从<code>0%</code>到<code>25%</code>是不带有透明度的红色，第二段从<code>25%</code>到<code>50%</code>是透明的，第三段从<code>50%</code>到<code>75%</code>又是带有<code>30%</code>透明度的白色，第四段从<code>75%</code>到<code>100%</code>是透明的。这样就形成了一个斜向的条纹效果</em>。通过以上理解线性渐变的概念。</p><p>颜色后边若是两个百分比值，则两个百分比之间的部分即为该颜色值，即一个起始值，一个终止值。若为一个值则起始值和终止值一样，两边会以这个位置向两边过度。如果两个或多个颜色终止在同一位置，则在该位置声明的第一个颜色和最后一个颜色之间的过渡将是一条生硬线。起始<code>0%</code>不需要设置。起始值和终止值统称为<u><strong>标志位</strong></u>。</p><div class="language-html line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#D19A66;">    .linear-gradient</span><span style="color:#ABB2BF;"> {</span></span>
<span class="line"><span style="color:#ABB2BF;">        height: </span><span style="color:#D19A66;">200</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        width: </span><span style="color:#D19A66;">200</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        border: </span><span style="color:#D19A66;">1</span><span style="color:#E06C75;">px</span><span style="color:#D19A66;"> solid</span><span style="color:#D19A66;"> #000</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        background-color: yellowgreen;</span></span>
<span class="line"><span style="color:#ABB2BF;">        background-image: </span><span style="color:#56B6C2;">linear-gradient</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">45</span><span style="color:#E06C75;">deg</span><span style="color:#ABB2BF;">, </span><span style="color:#56B6C2;">rgba</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">255</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">0</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">0</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">1</span><span style="color:#ABB2BF;">) </span><span style="color:#D19A66;">25</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">transparent</span><span style="color:#D19A66;"> 25</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">transparent</span><span style="color:#D19A66;"> 50</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#56B6C2;">rgba</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">255</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">255</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">255</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">.3</span><span style="color:#ABB2BF;">) </span><span style="color:#D19A66;">50</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#56B6C2;">rgba</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">255</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">255</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">255</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">.3</span><span style="color:#ABB2BF;">) </span><span style="color:#D19A66;">75</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">transparent</span><span style="color:#D19A66;"> 75</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">transparent</span><span style="color:#D19A66;"> 100</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#ABB2BF;">    }</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;/</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">div</span><span style="color:#D19A66;"> class</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;linear-gradient&quot;</span><span style="color:#ABB2BF;">&gt;&lt;/</span><span style="color:#E06C75;">div</span><span style="color:#ABB2BF;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><div class="linear-gradient"></div><h5 id="示例2" tabindex="-1">示例2 <a class="header-anchor" href="#示例2" aria-label="Permalink to &quot;示例2&quot;">​</a></h5><div class="language-html line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#D19A66;">    .linear-gradient-1</span><span style="color:#ABB2BF;"> {</span></span>
<span class="line"><span style="color:#ABB2BF;">        height: </span><span style="color:#D19A66;">200</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        width: </span><span style="color:#D19A66;">200</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        border: </span><span style="color:#D19A66;">1</span><span style="color:#E06C75;">px</span><span style="color:#D19A66;"> solid</span><span style="color:#D19A66;"> #000</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        background: </span><span style="color:#56B6C2;">linear-gradient</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">red</span><span style="color:#D19A66;"> 0</span><span style="color:#E06C75;">%</span><span style="color:#D19A66;"> 30</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">yellow</span><span style="color:#D19A66;"> 30</span><span style="color:#E06C75;">%</span><span style="color:#D19A66;"> 60</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">blue</span><span style="color:#D19A66;"> 30</span><span style="color:#E06C75;">%</span><span style="color:#D19A66;"> 100</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#ABB2BF;">    }</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;/</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">div</span><span style="color:#D19A66;"> class</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;linear-gradient-1&quot;</span><span style="color:#ABB2BF;">&gt;&lt;/</span><span style="color:#E06C75;">div</span><span style="color:#ABB2BF;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><div class="linear-gradient-1"></div><h5 id="绘制三角图形" tabindex="-1">绘制三角图形 <a class="header-anchor" href="#绘制三角图形" aria-label="Permalink to &quot;绘制三角图形&quot;">​</a></h5><div class="language-html line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#D19A66;">    .linear-gradient-4</span><span style="color:#ABB2BF;"> {</span></span>
<span class="line"><span style="color:#ABB2BF;">        height: </span><span style="color:#D19A66;">200</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        width: </span><span style="color:#D19A66;">200</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        border: </span><span style="color:#D19A66;">1</span><span style="color:#E06C75;">px</span><span style="color:#D19A66;"> solid</span><span style="color:#D19A66;"> #000</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        background-color: yellowgreen;</span></span>
<span class="line"><span style="color:#ABB2BF;">        background-image: </span><span style="color:#56B6C2;">linear-gradient</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">45</span><span style="color:#E06C75;">deg</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">yellow</span><span style="color:#D19A66;"> 50</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">red</span><span style="color:#D19A66;"> 50</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">        /* 等价于background-image: linear-gradient(45deg, yellow 0 50%, red 50% 100%);  */</span></span>
<span class="line"><span style="color:#ABB2BF;">    }</span></span>
<span class="line"><span style="color:#ABB2BF;">    &lt;/</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">div</span><span style="color:#D19A66;"> class</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;linear-gradient-4&quot;</span><span style="color:#ABB2BF;">&gt;&lt;/</span><span style="color:#E06C75;">div</span><span style="color:#ABB2BF;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><div class="linear-gradient-4"></div><div class="important custom-block github-alert"><p class="custom-block-title">结论</p><p>渐变区域即不连续数值的区域，如果连续则为硬过度。</p></div><h4 id="创建方块背景图" tabindex="-1">创建方块背景图 <a class="header-anchor" href="#创建方块背景图" aria-label="Permalink to &quot;创建方块背景图&quot;">​</a></h4><p>一个30px的小方块分为四个图片，通过<code>background-position</code>移动对应图片，每一个<code>linear-gradient</code>就是一个图片。</p><div class="language-html line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#D19A66;">    .linear-gradient-square</span><span style="color:#ABB2BF;"> {</span></span>
<span class="line"><span style="color:#ABB2BF;">        height: </span><span style="color:#D19A66;">90</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        background-size: </span><span style="color:#D19A66;">30</span><span style="color:#E06C75;">px</span><span style="color:#D19A66;"> 30</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        border: </span><span style="color:#D19A66;">1</span><span style="color:#E06C75;">px</span><span style="color:#D19A66;"> solid</span><span style="color:#ABB2BF;"> pink;</span></span>
<span class="line"><span style="color:#ABB2BF;">        background-position: </span><span style="color:#D19A66;">0</span><span style="color:#D19A66;"> 0</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">-15</span><span style="color:#E06C75;">px</span><span style="color:#D19A66;"> 15</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">15</span><span style="color:#E06C75;">px</span><span style="color:#D19A66;"> -15</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">0</span><span style="color:#D19A66;"> 0</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        background-image: </span><span style="color:#56B6C2;">linear-gradient</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">45</span><span style="color:#E06C75;">deg</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">red</span><span style="color:#D19A66;"> 25</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">transparent</span><span style="color:#D19A66;"> 0</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#ABB2BF;">        background-image: </span><span style="color:#56B6C2;">linear-gradient</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">45</span><span style="color:#E06C75;">deg</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">red</span><span style="color:#D19A66;"> 25</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">transparent</span><span style="color:#D19A66;"> 0</span><span style="color:#ABB2BF;">),</span></span>
<span class="line"><span style="color:#56B6C2;">            linear-gradient</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">45</span><span style="color:#E06C75;">deg</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">transparent</span><span style="color:#D19A66;"> 75</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">red</span><span style="color:#D19A66;"> 0</span><span style="color:#ABB2BF;">),</span></span>
<span class="line"><span style="color:#56B6C2;">            linear-gradient</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">45</span><span style="color:#E06C75;">deg</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">red</span><span style="color:#D19A66;"> 25</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">transparent</span><span style="color:#D19A66;"> 0</span><span style="color:#ABB2BF;">),</span></span>
<span class="line"><span style="color:#56B6C2;">            linear-gradient</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">45</span><span style="color:#E06C75;">deg</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">transparent</span><span style="color:#D19A66;"> 75</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">red</span><span style="color:#D19A66;"> 0</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#ABB2BF;">    }</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;/</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">div</span><span style="color:#D19A66;"> class</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;linear-gradient-square&quot;</span><span style="color:#ABB2BF;">&gt;&lt;/</span><span style="color:#E06C75;">div</span><span style="color:#ABB2BF;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><div class="linear-gradient-square"></div><h4 id="网格线" tabindex="-1">网格线 <a class="header-anchor" href="#网格线" aria-label="Permalink to &quot;网格线&quot;">​</a></h4><p>如果两个或多个颜色终止在同一位置，则在该位置声明的第一个颜色和最后一个颜色之间的过渡将是一条生硬线。</p><div class="language-html line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#D19A66;">    .linear-gradient-gradline</span><span style="color:#ABB2BF;"> {</span></span>
<span class="line"><span style="color:#ABB2BF;">        height: </span><span style="color:#D19A66;">90</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        background-size: </span><span style="color:#D19A66;">30</span><span style="color:#E06C75;">px</span><span style="color:#D19A66;"> 30</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        background-image: </span><span style="color:#56B6C2;">linear-gradient</span><span style="color:#ABB2BF;">(to </span><span style="color:#D19A66;">right</span><span style="color:#ABB2BF;">, pink </span><span style="color:#D19A66;">1</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">transparent</span><span style="color:#D19A66;"> 1</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">), </span><span style="color:#56B6C2;">linear-gradient</span><span style="color:#ABB2BF;">(pink </span><span style="color:#D19A66;">1</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">transparent</span><span style="color:#D19A66;"> 1</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#ABB2BF;">    }</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;/</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">div</span><span style="color:#D19A66;"> class</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;linear-gradient-gradline&quot;</span><span style="color:#ABB2BF;">&gt;&lt;/</span><span style="color:#E06C75;">div</span><span style="color:#ABB2BF;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><div class="linear-gradient-gradline"></div><h4 id="渐变重复" tabindex="-1">渐变重复 <a class="header-anchor" href="#渐变重复" aria-label="Permalink to &quot;渐变重复&quot;">​</a></h4><div class="language-html line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#D19A66;">    .linear-gradient-repeat</span><span style="color:#ABB2BF;"> {</span></span>
<span class="line"><span style="color:#ABB2BF;">        height: </span><span style="color:#D19A66;">100</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        background: </span><span style="color:#56B6C2;">repeating-linear-gradient</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">90</span><span style="color:#E06C75;">deg</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">blue</span><span style="color:#D19A66;"> 0</span><span style="color:#D19A66;"> 25</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">red</span><span style="color:#D19A66;"> 25</span><span style="color:#E06C75;">px</span><span style="color:#D19A66;"> 50</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#ABB2BF;">    }</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;/</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">div</span><span style="color:#D19A66;"> class</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;linear-gradient-repeat&quot;</span><span style="color:#ABB2BF;">&gt;&lt;/</span><span style="color:#E06C75;">div</span><span style="color:#ABB2BF;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><div class="linear-gradient-repeat"></div><h3 id="径向渐变" tabindex="-1">径向渐变 <a class="header-anchor" href="#径向渐变" aria-label="Permalink to &quot;径向渐变&quot;">​</a></h3><p>径向渐变和线性渐变原理一样，不一样的地方是需要定义圆心或者说是中心点。位置的关键字为<code>at</code>，</p><p><strong>设置渐变</strong></p><div class="language-css line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#C678DD;">background: radial-gradient(red</span><span style="color:#ABB2BF;">,</span><span style="color:#C678DD;"> blue</span><span style="color:#ABB2BF;">,</span><span style="color:#C678DD;"> green</span><span style="color:#ABB2BF;">);</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><strong>设置渐变宽度与高度</strong></p><div class="language-css line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#C678DD;">background: radial-gradient(100px 200px</span><span style="color:#ABB2BF;">,</span><span style="color:#C678DD;"> red</span><span style="color:#ABB2BF;">,</span><span style="color:#C678DD;"> blue</span><span style="color:#ABB2BF;">,</span><span style="color:#C678DD;"> green</span><span style="color:#ABB2BF;">);</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><strong>左下渐变</strong></p><div class="language-css line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#C678DD;">background: radial-gradient(at bottom left</span><span style="color:#ABB2BF;">,</span><span style="color:#C678DD;"> red</span><span style="color:#ABB2BF;">,</span><span style="color:#C678DD;"> blue</span><span style="color:#ABB2BF;">);</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><strong>右下渐变</strong></p><div class="language-css line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#C678DD;">background: radial-gradient(at bottom right</span><span style="color:#ABB2BF;">,</span><span style="color:#C678DD;"> red</span><span style="color:#ABB2BF;">,</span><span style="color:#C678DD;"> blue</span><span style="color:#ABB2BF;">);</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><strong>左侧向中心渐变</strong></p><div class="language-css line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#C678DD;">background: radial-gradient(at </span><span style="color:#E06C75;">center</span><span style="color:#C678DD;"> left</span><span style="color:#ABB2BF;">,</span><span style="color:#C678DD;"> red</span><span style="color:#ABB2BF;">,</span><span style="color:#C678DD;"> blue</span><span style="color:#ABB2BF;">);</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><strong>底部向中心渐变</strong></p><div class="language-css line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#C678DD;">background: radial-gradient(at 50% 100%</span><span style="color:#ABB2BF;">,</span><span style="color:#C678DD;"> red</span><span style="color:#ABB2BF;">,</span><span style="color:#C678DD;"> blue</span><span style="color:#ABB2BF;">);</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-html line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#D19A66;">    .linear-gradient-sun</span><span style="color:#ABB2BF;"> {</span></span>
<span class="line"><span style="color:#ABB2BF;">        width: </span><span style="color:#D19A66;">150</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        height: </span><span style="color:#D19A66;">150</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        background: </span><span style="color:#56B6C2;">radial-gradient</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">red</span><span style="color:#D19A66;"> 0</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">yellow</span><span style="color:#D19A66;"> 30</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">black</span><span style="color:#D19A66;"> 60</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">black</span><span style="color:#D19A66;"> 100</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#ABB2BF;">    }</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;/</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">div</span><span style="color:#D19A66;"> class</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;linear-gradient-sun&quot;</span><span style="color:#ABB2BF;">&gt;&lt;/</span><span style="color:#E06C75;">div</span><span style="color:#ABB2BF;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><h4 id="" tabindex="-1"><a class="header-anchor" href="#" aria-label="Permalink to &quot;&quot;">​</a></h4><pre><code>&lt;div class=&quot;linear-gradient-sun&quot;&gt;&lt;/div&gt;
</code></pre><h4 id="线性重复" tabindex="-1">线性重复 <a class="header-anchor" href="#线性重复" aria-label="Permalink to &quot;线性重复&quot;">​</a></h4><p>镜像重复从第一个颜色到最后一个颜色为一个单位去看，不可以整个元素背景去看，整个元素背景去看是看的元素的整体重复效果。</p><div class="language-html line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#D19A66;">    .linear-gradient-x-repeat</span><span style="color:#ABB2BF;"> {</span></span>
<span class="line"><span style="color:#ABB2BF;">        width: </span><span style="color:#D19A66;">350</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        height: </span><span style="color:#D19A66;">100</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        background: </span><span style="color:#56B6C2;">repeating-linear-gradient</span><span style="color:#ABB2BF;">(to </span><span style="color:#D19A66;">right</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">blue</span><span style="color:#D19A66;"> 0</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">25</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">yellow</span><span style="color:#D19A66;"> 100</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ABB2BF;">    }</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;/</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">div</span><span style="color:#D19A66;"> class</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;linear-gradient-x-repeat&quot;</span><span style="color:#ABB2BF;">&gt;&lt;/</span><span style="color:#E06C75;">div</span><span style="color:#ABB2BF;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><div class="linear-gradient-x-repeat"></div><p>加强版理解，这个可以理解为一个整体的宽度为<code>100px-20px=80px</code>，中心点位置为<code>50px-20px=30px</code>。最前边的黄色<code>30px</code>的区域可以理解为一个整体从后补齐，最后<code>20px</code>则是按顺序重复。</p><div class="language-html line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#D19A66;">    .linear-gradient-x-repeat-xx</span><span style="color:#ABB2BF;"> {</span></span>
<span class="line"><span style="color:#ABB2BF;">        width: </span><span style="color:#D19A66;">350</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        height: </span><span style="color:#D19A66;">100</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        background: </span><span style="color:#56B6C2;">repeating-linear-gradient</span><span style="color:#ABB2BF;">(to </span><span style="color:#D19A66;">right</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">blue</span><span style="color:#D19A66;"> 20</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">50</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">yellow</span><span style="color:#D19A66;"> 100</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ABB2BF;">    }</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;/</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">div</span><span style="color:#D19A66;"> class</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;linear-gradient-x-repeat-xx&quot;</span><span style="color:#ABB2BF;">&gt;&lt;/</span><span style="color:#E06C75;">div</span><span style="color:#ABB2BF;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><div class="linear-gradient-x-repeat-xx"></div><h4 id="径向重复" tabindex="-1">径向重复 <a class="header-anchor" href="#径向重复" aria-label="Permalink to &quot;径向重复&quot;">​</a></h4><p>100%为整体，0-25%为一个重复单位的四分之一，所以一共是四圈，占满整个元素，然后重复向外扩展。</p><div class="language-html line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#D19A66;">    .linear-gradient-y-repeat</span><span style="color:#ABB2BF;"> {</span></span>
<span class="line"><span style="color:#ABB2BF;">        width: </span><span style="color:#D19A66;">200</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        height: </span><span style="color:#D19A66;">200</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#ABB2BF;">        background: </span><span style="color:#56B6C2;">repeating-radial-gradient</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">100</span><span style="color:#E06C75;">px</span><span style="color:#D19A66;"> 100</span><span style="color:#E06C75;">px</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">red</span><span style="color:#D19A66;"> 0</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">yellow</span><span style="color:#D19A66;"> 25</span><span style="color:#E06C75;">%</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#ABB2BF;">    }</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;/</span><span style="color:#E06C75;">style</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;">&lt;</span><span style="color:#E06C75;">div</span><span style="color:#D19A66;"> class</span><span style="color:#ABB2BF;">=</span><span style="color:#98C379;">&quot;linear-gradient-y-repeat&quot;</span><span style="color:#ABB2BF;">&gt;&lt;/</span><span style="color:#E06C75;">div</span><span style="color:#ABB2BF;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><div class="linear-gradient-y-repeat"></div></div></div></main><footer class="VPDocFooter" data-v-39a288b8 data-v-e257564d><!--[--><!--]--><div class="edit-info" data-v-e257564d><!----><div class="last-updated" data-v-e257564d><p class="VPLastUpdated" data-v-e257564d data-v-e98dd255>最后更新: <time datetime="2024-12-30T14:20:32.000Z" data-v-e98dd255></time></p></div></div><nav class="prev-next" aria-labelledby="doc-footer-aria-label" data-v-e257564d><span class="visually-hidden" id="doc-footer-aria-label" data-v-e257564d>Pager</span><div class="pager" data-v-e257564d><a class="VPLink link pager-link prev" href="/frontend/css/%E7%9B%92%E5%AD%90%E6%A8%A1%E5%9E%8B.html" data-v-e257564d><!--[--><span class="desc" data-v-e257564d>上一篇</span><span class="title" data-v-e257564d>盒子模型</span><!--]--></a></div><div class="pager" data-v-e257564d><a class="VPLink link pager-link next" href="/frontend/css/%E9%80%89%E6%8B%A9%E5%99%A8.html" data-v-e257564d><!--[--><span class="desc" data-v-e257564d>下一篇</span><span class="title" data-v-e257564d>选择器</span><!--]--></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><!----><!--[--><!--]--></div></div>
    
    
  </body>
</html>